package meihua.stopcarapp.model;

import java.util.List;

import meihua.mylibrary.basebean.ResultModel;
import meihua.mylibrary.baserx.RxSchedulers;
import meihua.stopcarapp.api.Api;
import meihua.stopcarapp.api.URLType;
import meihua.stopcarapp.bean.SpendEntity;
import meihua.stopcarapp.presenter.contract.SpendContract;
import rx.Observable;
import rx.functions.Func1;

/**
 * Name: LGZ
 * Time: 2017/5/18.
 * Dec:
 */

public class SpendModel implements SpendContract.Model {
    @Override
    public Observable<List<SpendEntity>> getSpendList(String user_id, String num) {
        return Api.getDefault(URLType.STOPCAR_URL)
                .getSpendList(user_id, num)
                .map(new Func1<ResultModel<List<SpendEntity>>, List<SpendEntity>>() {
                    @Override
                    public List<SpendEntity> call(ResultModel<List<SpendEntity>> resultModel) {
                        return resultModel.getData();
                    }
                })
                .compose(RxSchedulers.<List<SpendEntity>>io_main());
    }
}
